package Graphique;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ExpandBar;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Sash;
import org.eclipse.swt.widgets.Text;
import Command.Command;
import Command.CommandNext;
import Command.CommandPrev;
import Command.CommandReset;
import Command.CommandSave;
import Command.CommandSearch;
import Connexion.ChargeurdeDonnees;
import Connexion.mysqlConnector;
import Listener.ButtonListener;


/** <p>
 * @author Tangi Midy
 * 	For personal applications *       
 *  </p>
 *  <p>
 * @version 2.0 *        
 * New enhanced version of the movie pointer
 * </p>
 * <p>MoviePointerTabOne : the first tab representing the global film features</p>
 */
public class MoviePointerTabOne extends Composite {

	private CompositeCenter compositeCenter = null;
	private List listFilms = null;
	private FormData  compositeData;
	private ExpandedSearch expandSearch;
	private Command commandNew, commandPrev, commandNext, commandSave, commandSearch,
			commandReset;
	private MainFrame main;
	
	/**
	 * Constructor of the class
	 */
	public MoviePointerTabOne(Composite parent, int style) {
		super(parent, style);
		
		createsFormData();
		initCenter();
		initCommands();		
	}

	private void initCommands() {

		commandPrev = new CommandPrev();

		commandPrev.setCompositeCenter(compositeCenter);

		commandNext = new CommandNext();

		commandNext.setCompositeCenter(compositeCenter);

		commandSave = new CommandSave();

		commandSave.setCompositeCenter(compositeCenter);

	

		compositeCenter.getNext().addListener(SWT.Selection,
				new ButtonListener(commandNext));
		compositeCenter.getPrev().addListener(SWT.Selection,
				new ButtonListener(commandPrev));
		compositeCenter.getSave().addListener(SWT.Selection,
				new ButtonListener(commandSave));
	}

	private void initCenter() {
		compositeCenter = new CompositeCenter(this, SWT.BORDER);
		compositeCenter.setLayoutData(compositeData);
	}

	private void createsFormData() {
		this.setLayout(new FormLayout());
	}

	public void setFilm(String name){
		this.compositeCenter.initFields(name, this.main);	
	}
	
	public void setMainFrame(MainFrame main){
		this.main = main;
		compositeCenter.setMainFrame(this.main);
	}
	
	public void setListReferences(){
		this.listFilms=main.getList();
		commandSave.setListeFilms(listFilms);
		commandNext.setListeFilms(listFilms);
		commandPrev.setListeFilms(listFilms);
	}
	
	
}
